package io.outputStream;

import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;

public class StuOutputStream {
    @Test
    public void test01() throws Exception {
        String path = "f:\\重头来过\\javaio\\a.txt";
        FileOutputStream fileOutputStream = new FileOutputStream(path);

        String s = "hello world 666";
        //两种写法都可以
        fileOutputStream.write(s.getBytes(),0,s.length());
        //fileOutputStream.write(s.getBytes(),0,s.getBytes().length);

        fileOutputStream.close();
    }

    @Test
    public void test02() throws Exception {
        String path = "f:\\重头来过\\javaio\\a.txt";
        FileOutputStream fileOutputStream = new FileOutputStream(path,true);

        String s = "hello world 666";
        //两种写法都可以
        fileOutputStream.write(s.getBytes(),0,s.length());

        fileOutputStream.close();
    }
}
